package com.example.tool.task.networkTool;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

import javax.xml.transform.Result;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName Posttest
 * @Author 13403
 * @Date 2022/4/2914:18
 * @Version 1.0
 **/
public class Posttest {
    public static void main1(String[] args) {
        String loginUrl="http://172.17.30.32:8086/ss/sys/api/login";
        //调用登陆接口返回key
        RestTemplate restTemplate=new RestTemplate();
        JSONObject login=new JSONObject();
        login.put("username","lis");
        login.put("password","123qwe!@#");
        ResponseEntity<String> responseEntity = restTemplate.postForEntity(loginUrl, login, String.class);
        JSONObject keyResult = JSONObject.parseObject(responseEntity.getBody());
        String key = keyResult.get("result").toString();
        HttpHeaders header = new HttpHeaders();
        header.set("X-Access-Token", key);
        header.set("Content-Type","application/json;charset=utf-8");
        String importHpvUrl = "http://172.17.30.32:8086/ss/api/lims/importLimsHpvResult";
        Map<String, String> map=new HashMap<>();
        map.put("barCode","barCode");
        map.put("hpvStatus","hpvStatus");
        String hpvJsonString = JSON.toJSONString(map);
        HttpEntity<String> codeAndStatus = new HttpEntity<String>(hpvJsonString, header);
//        Result hpvResult = restTemplate.postForObject(importHpvUrl, codeAndStatus,);
    }

    public static void main(String[] args) {
//        DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
//        Date date = new Date("2022-03-04");
//        System.out.println(date);

        String  daty="11";
        String substring = daty.substring(0, 4);
        System.out.println(substring);
    }
}
